package demo.spring.data.flow.c;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by lushun.chen on 2017/3/30.
 *
 * @author lushun.chen
 */
@Component
public class LoggingProcessor {

    private final KafkaTemplate kafkaTemplate;

    @Autowired
    public LoggingProcessor(KafkaTemplate kafkaTemplate) {
        this.kafkaTemplate = kafkaTemplate;
    }

    @Scheduled(cron = "0/5 * *  * * ? ")
    public void timerEntitySource() {
        System.out.println("1234567890");
        Map<String, Object> map = new HashMap<>();
        map.put("date", new Date());
        map.put("msg", "我是一个兵------I am ok");
        kafkaTemplate.send("test", map.toString());
    }
}
